package org.lex.awt;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Vector;

import javax.swing.JComboBox;
import javax.swing.JPanel;

import org.lex.swing.Swings;
import org.lex.swing.widgets.GradientLabel;
import org.lex.utils.Pair;


/**
 * @author Daniel Liu
 */
public class Colors {
	public static class Diskeeper {
		public static final Pair<Color, Color> BLUE = create(69, 137, 242, 3, 53, 172);
		public static final Pair<Color, Color> WHITE = create(255, 255, 255, 220, 217, 220);
		public static final Pair<Color, Color> YELLOW = create(255, 229, 78, 196, 154, 5);
		public static final Pair<Color, Color> GREEN = create(82, 246, 92, 13, 176, 39);
		public static final Pair<Color, Color> LIGHT_BLUE = create(51, 255, 255, 2, 195, 207);
	}

	public static class Windows {
		public static final Pair<Color, Color> XP_START_MENU = create(67, 139, 227, 12, 86, 192);
		public static final Pair<Color, Color> MC_START_MENU = create(118, 161, 222, 63, 102, 188);
	}

	public static class Sina {
		public static final Pair<Color, Color> LIGHT_BLUE = create(216, 229, 248, 170, 196, 232);
	}

	private static Pair<Color, Color> create(int r1, int g1, int b1, int r2, int g2, int b2) {
		return Pair.wrap(new Color(r1, g1, b1), new Color(r2, g2, b2));
	}

	public static void main(String[] args) {
		// color
		final Vector<Pair<Color, Color>> colors = new Vector<Pair<Color, Color>>();
		colors.add(Diskeeper.BLUE);
		colors.add(Diskeeper.WHITE);
		colors.add(Diskeeper.YELLOW);
		colors.add(Diskeeper.GREEN);
		colors.add(Diskeeper.LIGHT_BLUE);
		colors.add(Windows.XP_START_MENU);
		colors.add(Windows.MC_START_MENU);
		colors.add(Sina.LIGHT_BLUE);
		// label
		final GradientLabel label = new GradientLabel(Diskeeper.BLUE.first(), Diskeeper.BLUE.second());
		// combo
		final JComboBox combo = new JComboBox(colors);
		combo.addActionListener(new ActionListener() {
			@SuppressWarnings("unchecked")
			@Override
			public void actionPerformed(ActionEvent e) {
				Pair<Color, Color> c = (Pair<Color, Color>) combo.getSelectedItem();
				if (null != c)
					label.setColors(c.first(), c.second());
			}
		});
		JPanel pane = new JPanel(new BorderLayout());
		pane.add(combo, BorderLayout.NORTH);
		pane.add(label, BorderLayout.CENTER);
		Swings.show(pane, false);
	}
}
